import request from '@/utils/request'
import {proxyPrefix} from '../utils/index'

export function jobEnums() {
  return request({
    url: proxyPrefix + '/jobinfo/enums',
    method: 'get'
  })
}

export function getJobPageList(params) {
   return request({
    url: proxyPrefix + '/jobinfo/pageList',
    method: 'post',
    data: params
  })
}

export function getJobsByGroup(groupId) {
  return request({
    url: proxyPrefix + '/jobinfo/jobsByGroup',
    method: 'get',
    params: {groupId: groupId}
  })
}

export function create(params) {
  return request({
    url: proxyPrefix + '/jobinfo/add',
    method: 'post',
    data: params
  })
}

export function remove(id) {
  return request({
    url: proxyPrefix + '/jobinfo/remove',
    method: 'get',
    params: {id: id}
  })
}

export function update(params) {
  return request({
    url: proxyPrefix + '/jobinfo/update',
    method: 'post',
    data: params
  })
}
//执行一次触发
export function jobTrigger(param) {
  return request({
    url: proxyPrefix + '/jobinfo/trigger',
    method: 'post',
    data: param
  })
}

export function nextTriggerTime(scheduleType,scheduleConf) {
  return request({
    url: proxyPrefix + '/jobinfo/nextTriggerTime',
    method: 'post',
    data: 'scheduleType='+scheduleType+'&scheduleConf='+scheduleConf
  })
}

export function jobStart(id) {
  return request({
    url: proxyPrefix + '/jobinfo/start',
    method: 'post',
    data: 'id='+id
  })
}

export function jobStop(id) {
  return request({
    url: proxyPrefix + '/jobinfo/stop',
    method: 'post',
    data: 'id='+id
  })
}
